package com.qd.common.panda.domain.entity.carpark;

import com.cdqidi.util.page.BaseQuery;
import com.cdqidi.valid.group.DefaultGroup;
import com.cdqidi.valid.group.DeleteGroup;
import com.cdqidi.valid.group.UpdateGroup;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;
import java.util.Optional;


/**
 * 加油站扩展信息
 *
 * @author sjk
 */
@EqualsAndHashCode(callSuper = true)
@Getter
@Setter
@ToString
public class CarParkGasStationDTO extends BaseQuery {

    /**
     * 主键
     */
    @NotBlank(message = "停车场标识不能为空", groups = {DeleteGroup.class, UpdateGroup.class})
    @Size(max = 50, message = "停车场标识长度不能超过{max}位", groups = {DeleteGroup.class, UpdateGroup.class})
    @JsonProperty("pId")
    private String pId;
    /**
     * 加油站ID:同步第三方数据的加油站ID
     */
    @NotBlank(message = "加油站ID:同步第三方数据的加油站ID不能为空", groups = DefaultGroup.class)
    @Size(max = 64, message = "加油站ID:同步第三方数据的加油站ID长度不能超过{max}位", groups = DefaultGroup.class)
    private String stationId;
    /**
     * 折扣
     */
    @NotNull(message = "折扣不能为空", groups = DefaultGroup.class)
    private Double customerDiscount;
    /**
     * 加油站公司名称
     */
    @NotBlank(message = "加油站公司名称不能为空", groups = DefaultGroup.class)
    @Size(max = 20, message = "加油站公司名称长度不能超过{max}位", groups = DefaultGroup.class)
    private String gasStationCompanyName;
    /**
     * 加油站公司名称显示
     */
    private String gasStationCompanyNameDisplay;
    /**
     * 油站类型
     */
    private String stationType;
    /**
     * 油站类型显示
     */
    private String stationTypeDisplay;
    /**
     * 广告
     */
    private JsonNode advert;
    /**
     * 枪号，逗号隔开
     */
    @Size(max = 200, message = "枪号，逗号隔开长度不能超过{max}位", groups = DefaultGroup.class)
    private String nozzleNumbers;
    /**
     * 油耗价格
     */
    private List<CarParkGasStationPriceDTO> gasStationPriceList;
    /**
     * 油枪号信息
     */
    private List<CarParkGasStationNozzleDTO> gasStationNozzleList;
    @Override
    public void freeData() {
        this.pId = null;
        this.stationId = null;
        this.customerDiscount = null;
        this.gasStationCompanyName = null;
        this.gasStationCompanyNameDisplay = null;
        this.nozzleNumbers = null;
        this.stationType = null;
        this.stationTypeDisplay = null;
        this.advert = null;
        Optional.ofNullable(gasStationPriceList).ifPresent(List::clear);
        Optional.ofNullable(gasStationNozzleList).ifPresent(List::clear);
        super.freeData();
    }
}
